<template>
  <div style="width: 100%">
    <div class="collectionGoods" v-for="item of orderList[0]" :key="item.id">
      <el-card>
        <div class="collectionGoodImg">
          <img :src="'http://localhost:5000/files/' + item.imageId" alt="" />
        </div>

        <div class="collectionGoodBtn">
          <el-button type="primary" @click="jiesuan(item)" v-if="item.state=='未支付'">结算</el-button>
          
        </div>

        <div class="collectionGoodMsg">
          <div class="shopTitle">
            <h3>订单号：{{ item.id }}</h3>
          </div>
          <div class="shopIntroduction">
            <h3>店铺：小猪giao奇之家</h3>
          </div>
          <div class="shopIntroduction">
            <h3>商品：{{ item.spuname }}×{{ item.num }}</h3>
          </div>
          <!-- <div class="shopIntroduction">
            <h3>规格：</h3>
          </div> -->
          <div class="shopIntroduction">
            <h3>商品单价：{{ item.price }}</h3>
          </div>
          <div class="shopIntroduction">
            <h3>商品总价：{{ item.price * item.num }}</h3>
          </div>
          <div class="shopIntroduction">
            <h3>支付状态：{{item.state }}</h3>
          </div>
        </div>
      </el-card>
    </div>

    
  </div>
</template>

<script>
import { useridList } from "../api/home";
import Cookies from "js-cookie";
export default {
  data() {
    return {
      orderList: [],
    };
  },
  mounted() {
    useridList(this.uId).then((data) => {
      console.log(data.data.order);
      this.orderList.push(data.data.order);
      console.log(this.orderList);
    });
  },
  computed: {
    uId() {
      return Cookies.get("id");
    },
    },
    methods:{
      jiesuan(item)
      {
        console.log(item.id);
        this.$router.push('/checkOut?orderid='+item.id)
      }
  },
};
</script>

<style scoped>
.collectionGoodImg {
  width: 259px;
  height: 200px;
}
.collectionGoodBtn {
  margin-top: 10px;
  margin-left: 90%;
}
.collectionGoodMsg {
  width: 500px;
  height: 300px;
  margin-left: 300px;
  margin-top: -230px;
}
img {
  width: 100%;
  height: 100%;
}
.deleteOrder {
  margin-left: 58px;
}
.allGoods {
  margin-top: 10px;
  margin-left: 1000px;
}
</style>